package com.shenmazong.serverapisafe.config;

import com.shenmazong.serverapisafe.filter.ApiInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: server-java-demo
 * @description: WebMvcConfig
 * @author: 亮子说编程
 * @create: 2020-12-01 09:06
 **/

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Bean
    public ApiInterceptor apiInterceptor() {
        return new ApiInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //这里我们添加了一个测试的路径
        registry.addInterceptor(apiInterceptor()).addPathPatterns("/test/limit");
    }
}
